﻿using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using System.Data;
using System.Data.SqlClient;

namespace DAO
{
    public class NhanVien_DAO
    {
        public static string layMaNV(string username)
        {
            string query = "select MaNV from NHANVIEN where Username = '" + username + "'";

            DataTable dt = SqlDataAccessHelper.ExecuteQuery(query);
            string MaNV = string.Empty;
            foreach (DataRow dr in dt.Rows)
            {
                MaNV = dr["MaNV"].ToString();
            }
            return MaNV;
        }

        //dang nhap
        public static int dangNhap(string username, string password)
        {
            string query = "select * from NHANVIEN where Username = '" + username + "' and Password = '" + password + "'";

            DataTable dt = SqlDataAccessHelper.ExecuteQuery(query);

            if (dt.Rows.Count == 1)
            {
                return int.Parse(dt.Select()[0]["MaNV"].ToString()[0].ToString());
            }
            return 0;
        }
    }
}
